import api from '../api/index.js';

const state = {
    fcid: "51249",
    title: "",
    page: "1",
    sort: "pop",
    sortTitle: [],
    guessLike: [],
}

const actions = {
    searchLoad(store, str) {
        api.classMiniWall({
            fcid: store.state.fcid,
            title: store.state.title,
            page: store.state.page,
            sort: store.state.sort,
            cKey: 16,
        }).then((data) => {
            if (!data.success) {
                return Promise.reject("错误");
            }
            store.commit("setSortTitle", data.result.sortFilter);
            store.commit("setSearchGuessLike", data.result.wall.docs);
        }).catch((error) => {

        })
    },
}

const mutations = {
    setSearchFcid(state, nv) {
        state.fcid = nv;
    },
    setSearchTitle(state, nv) {
        state.title = nv;
    },
    setSearchPage(state, nv) {
        state.page = nv;
    },
    setSearchSort(state, nv) {
        state.sort = nv;
    },
    setSortTitle(state, nv) {
        state.sortTitle = nv;
    },
    setSearchGuessLike(state, nv) {
        state.guessLike = nv;
    },
}

export default {
    state,
    actions,
    mutations
}